export interface ActionType {
	type: string,
	payload?: any
}
export interface StateType {
	dropDownData: any[],
	modalData: any[],
	loading: boolean,
	total: number,
	value?: string | string[],
	[propsname: string]: any,
	filterInfo: any,
	params:any
}
export const initState: StateType = {
	dropDownData: [],
	modalData: [],
	loading: false,
	total: 0,
	value: "",
	filterInfo: {},
	params: {
		beginIndex: 0,
		pageSize: 50
	},
}
export function reducer(state: StateType, action: ActionType) {
	const { type, payload } = action;
	switch (type) {
		case "save":
			return { ...state, ...payload }
		case "saveValue": {
			return { ...state, value: payload }
		}
		case "saveDropDownData": {
			return { ...state, dropDownData: payload }
		}
		case "initModal": {
			return {
				...state,
				loading: false,
				filterInfo: {},
				pageInfo: {
					pageSize: 25,
					beginIndex: 0
				},
				modalData: [],
			}
		}
	}
}